<template>
  <view class="container">
    <web-view src="https://www.crossbordertrade.cn/wemy?time=222" @message="getMessage"></web-view>
  </view>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';

const message = ref('');

const getMessage = (e: any) => {
  console.log(111,e);
  message.value = e.detail.data;
};

// 获取录音权限
const getRecordAuth = () => {
  uni.authorize({
    scope: 'scope.record',
    success() {
      console.log('已获取录音权限');
    },
    fail() {
      uni.showModal({
        title: '提示',
        content: '需要您的录音权限，是否去设置打开？',
        confirmText: '去设置',
        cancelText: '取消',
        success: (res) => {
          if (res.confirm) {
            uni.openSetting({
              success(settingRes) {
                console.log('设置录音权限结果：', settingRes);
              }
            });
          }
        }
      });
    }
  });
};

// 页面加载时获取权限
onMounted(() => {
  getRecordAuth();
});
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100vh;
}
</style>
